package com.zjdiepu.www.ibiz.yw;

import java.net.SocketTimeoutException;
import java.util.List;
import java.util.Set;

import com.zjdiepu.www.base.core.AbstractSysUser;
import com.zjdiepu.www.base.core.ApiResponse;
import com.zjdiepu.www.base.enums.status.CheckEstimateResultStatus;
import com.zjdiepu.www.base.enums.type.OperateType;
import com.zjdiepu.www.base.lang.HttpClientException;
import com.zjdiepu.www.model.base.dto.SysUser;
import com.zjdiepu.www.model.base.ext.ClientTypeExt;
import com.zjdiepu.www.model.base.vo.BusinessTotalVo;
import com.zjdiepu.www.model.third.request.juhe.JuheExactEstimationRequest;
import com.zjdiepu.www.model.yw.dto.YwBusiness;
import com.zjdiepu.www.model.yw.ext.YwBusinessExt;
import com.zjdiepu.www.model.yw.request.ChangeChannelRequest;
import com.zjdiepu.www.model.yw.request.YwBusinessQueryRequest;
import com.zjdiepu.www.model.yw.response.YwBusinessDetail;

/**
 * 业务信息Service层操作<br/>
 * @author xiongxiaotun<br/>
 * @time 2017年04月24日 14时45分<br/>
 * @since 1.0<br/>
 */
public interface IYwBusinessService {
	
	/**
	 * 条件修改
	 * @param ywBusiness
	 * @param ywBusinessExt
	 */
	void updateByExt(YwBusiness ywBusiness, YwBusinessExt ywBusinessExt);
	
	/**
	 * 修改订单类型
	 * @author xiongxiaotun <br/>
	 * @Title saveChangeChannel  <br/>
	 * @Description 修改订单类型 <br/>
	 * @param changeChannelRequest
	 * @param sysUser
	 * @version V1.0  <br/>
	 */
	void saveChangeChannel(ChangeChannelRequest changeChannelRequest, SysUser sysUser);
	/**
	 * 订单退回
	 * @author xiongxiaotun <br/>
	 * @Title: saveRefuseSace  <br/>
	 * @Description: 订单退回 <br/>
	 * @param id
	 * @param sysUser
	 * @return
	 * @version V1.0  <br/>
	 */
	void saveRefuseSace(String id, SysUser sysUser);
	/**
	 * 提交终审
	 * @author xiongxiaotun <br/>
	 * @Title: saveComitFinal  <br/>
	 * @Description: 提交终审 <br/>
	 * @param id
	 * @param sysUser
	 * @return
	 * @version V1.0  <br/>
	 */
	void saveComitFinal(String id, SysUser sysUser,String serverRealPath);
	/**
	 * 多表查询
	 * @date 2017年04月24日 14时45分
	 * @param customerNo
	 * @return
	 */
	List<YwBusiness> selectByCustomerNo(String customerNo);
	 /**
     * @author xiongxiaotun <br/>
     * @Title: updateForApplayAllocation <br/>
     * @Description: 申请派单<br/>
     * @param allocationNum
     * @param sysUser 登录用户
     * @return
     * @version V1.0  <br/>
     */
    void updateForApplyAllocation(int allocationNum, SysUser sysUser);
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: saveAllocation  <br/>
	 * @Description: 分配任务  <br/>
	 * @param id
	 * @param operatorId
	 * @param operatorName
	 * @param currentUser
	 * @return
	 * @version V1.0  <br/>
	 */
	ApiResponse saveAllocation(String id, String operatorId, String operatorName, AbstractSysUser currentUser);
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: queryHistoryByCustomerNo  <br/>
	 * @Description: 根据客户身份证号查询历史业务 <br/>
	 * @param customerNo
	 * @version V1.0  <br/>
	 */
	String queryHistoryByCustomerNo(String customerNo);
	/**
	 * 新增,更新和保存
	 * 
	 * @param YwBusiness 
	 * @param OperateType 操作类型 {@link OperateType}
	 */
	void saveUpdateAndDelete(YwBusiness ywBusiness,OperateType operType);
	
	/**
	 * 条件查询
	 * @date 2017年04月24日 14时45分
	 * @param ywBusinessExt
	 * @return
	 */
	List<YwBusiness> selectByExt(YwBusinessExt ywBusinessExt);
	
	/**
	 * 多表查询
	 * @date 2017年04月24日 14时45分
	 * @param ywBusinessQueryRequest
	 * @return
	 */
	List<YwBusiness> selectMultiByExt(YwBusinessQueryRequest ywBusinessQueryRequest);
	/**
	 * 精确定位客户查询
	 * @date 2017年04月24日 14时45分
	 * @param ywBusinessQueryRequest
	 * @return
	 */
	List<YwBusiness> selectLessOptionsByExt(YwBusinessQueryRequest ywBusinessQueryRequest);
	
	/**
	 * 条件统计
	 * @date 2017年04月24日 14时45分
	 * @param ywBusinessExt
	 * @return
	 */
	int countByExt(YwBusinessExt ywBusinessExt);

	/**
	 * 多表统计
	 * @param ywBusinessQueryRequest
	 * @return
	 */
	int countMultiByExt(YwBusinessQueryRequest ywBusinessQueryRequest);
	
	/**
	 * 精确定位客户统计
	 * @param ywBusinessQueryRequest
	 * @return
	 */
	int countLessOptionsByExt(YwBusinessQueryRequest ywBusinessQueryRequest);
	
	/**
	 * 主键查询
	 * @date 2017年04月24日 14时45分
	 * @param id
	 * @return
	 */
	YwBusiness selectById(String id);
	
	/**
	 * 主键多表查询
	 * @date 2017年04月24日 14时45分
	 * @param id
	 * @return
	 */
	YwBusinessDetail getMultiById(String id);
	
	/**
	 * 根据主键清除空字段，设置值为null
	 * @date 2017年04月24日 14时45分
	 * @param fieldNames 字段名
	 * @param id 主键
	 */
	void clearEmpty(Set<String> fieldNames, String id);
	/**
	 * 精确统计(=)
	 * @author xiongxiaotun
	 * @time 2017年04月24日 14时45分
	 * @since 1.0
	 * @update
	 * @param sysPower
	 * @return
	 */
	int countRefined(YwBusiness ywBusiness);
	/**
	 * 精确查询(=)
	 * @author xiongxiaotun
	 * @time 2017年04月24日 14时45分
	 * @since 1.0
	 * @update
	 * @param ywBusiness
	 * @return
	 */
	YwBusiness selectRefined(YwBusiness ywBusiness);
	/**
	 * @author xiongxiaotun <br/>
	 * @Title repeat  <br/>
	 * @Description 判断是否重复 <br/>
	 * @param ywBusiness
	 * @return
	 * @version V1.0  <br/>
	 */
	boolean repeat(YwBusiness ywBusiness);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: updateBatch  <br/>
	 * @Description:批量删除/禁用/启用  <br/>
	 * @param modifier 修改人
	 * @param modifierName 修改人名称
	 * @param dpStatus 修改后状态
	 * @param ids 待修改数据ID
	 * @return
	 * @version V1.0  <br/>
	 */
	int updateBatch(String modifier, String modifierName, Integer dpStatus, List<String> ids);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: updateCommonBatch  <br/>
	 * @Description:批量修改  <br/>
	 * @param ywBusiness 修改后数据
	 * @param ids 待修改数据ID
	 * @return
	 * @version V1.0  <br/>
	 */
	int updateCommonBatch(YwBusiness ywBusiness, List<String> ids);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: saveYwBusinessCarAreaPrice  <br/>
	 * @Description: 聚合数据：二手车接口：估值<br/>
	 * @param request
	 * @param currentUser
	 * @return
	 * @version V1.0  <br/>
	 * @throws HttpClientException 
	 * @throws SocketTimeoutException 
	 */
	ApiResponse saveYwBusinessCarAreaPrice(JuheExactEstimationRequest request, AbstractSysUser currentUser);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: checkIfNeedEstimate <br/>
	 * @Description: 判断是否需要估价 <br/>
	 * @param request
	 * @return
	 * @version V1.0  <br/>
	 * @throws HttpClientException 
	 * @throws SocketTimeoutException 
	 */
	CheckEstimateResultStatus checkIfNeedEstimate(JuheExactEstimationRequest request);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: countNotAllocation <br/>
	 * @Description: 统计未分配客户资料 <br/>
	 * @param ywBusinessExt
	 * @return 指定部门客户资料数
	 * @version V1.0  <br/>
	 */
	int countNotAllocation(YwBusinessExt ywBusinessExt);
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: selectNotAllocation <br/>
	 * @Description: 查询未分配客户资料 <br/>
	 * @param ywBusinessExt
	 * @return 指定部门客户资料
	 * @version V1.0  <br/>
	 */
	List<YwBusiness> selectNotAllocation(YwBusinessExt ywBusinessExt);
	
	/**
     * @author xiongxiaotun <br/>
     * @Title: randomAllocation <br/>
     * @Description: 随机资料登记客户派单<br/>
     * @param allocationNum
     * @param sysUser 登录用户
     * @return
     * @version V1.0  <br/>
     */
    public void updateForRandomAllocation(int allocationNum, SysUser sysUser);
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: saveCompleted  <br/>
     * @Description: 检查信息是否完整 <br/>
     * @param id
     * @param currentUser
     * @param ifPhone
     * @param channelType 
     * @return
     * @version V1.0  <br/>
     */
    public ApiResponse saveCompleted(String id, AbstractSysUser currentUser, boolean ifPhone, String channelType);
	/**
	 * 修改业务还款状态
	 * @param ywExt
	 */
	void updateRefundStatus(YwBusinessExt ywExt);
	void modifyAll(YwBusiness ywBusiness, AbstractSysUser currentUser);
	int countBusinessNum(ClientTypeExt clientTypeExt);
	List<BusinessTotalVo> selectBusinessNum(ClientTypeExt clientTypeExt);
	int countXHHNum(ClientTypeExt clientTypeExt);
	List<BusinessTotalVo> selectXHHNum(ClientTypeExt clientTypeExt);
	int countAllBusinessNum(ClientTypeExt clientTypeExt);
	int countAllXHHNum(ClientTypeExt clientTypeExt);
	void updateOpenCardStatus(String busiId,SysUser currentUser);
}
